

#define DEVICE_NAME "ST_001"
#define PRODUCT_NAME "9BXG6M4BH5"
#define DEVICE_TOKEN "version=2018-10-31&res=products%2F9BXG6M4BH5%2Fdevices%2FST_001&et=2527331264&method=md5&sign=D5mxZj9Z02DZhtURiaejCQ%3D%3D"

// #define DEVICE_NAME "ST_002"
// #define PRODUCT_NAME "9BXG6M4BH5"
// #define DEVICE_TOKEN "version=2018-10-31&res=products%2F9BXG6M4BH5%2Fdevices%2FST_002&et=2527331264&method=md5&sign=Oae8%2B5fuzjHngjvxzVsRLw%3D%3D"


//花瓶大小设置系数
//大花瓶3~6分钟对应系数 60 ；
//微型花瓶 15秒~30秒 对应系数5
#define g_SleepTimeCoff 5  

#define WORK_STATE_INIT 0
#define WORK_STATE_IDLE 1
#define WORK_STATE_WORK 2
#define WORK_STATE_TIMESET 3  //任务时间 *
#define WORK_STATE_TEST 4
#define WORK_STATE_PREPARE_SLEEP 5  //
#define WORK_STATE_STUDY 6  //wifi
#define WORK_STATE_SLEEP 7

#define IR_CMD_OK 28
#define IR_CMD_UP 24
#define IR_CMD_DOWN 82
#define IR_CMD_LEFT 8
#define IR_CMD_RIGHT 90
#define IR_CMD_FLAGJIN 13
#define IR_CMD_FLAGXING 22
#define IR_CMD_0 25
#define IR_CMD_1 69
#define IR_CMD_2 70
#define IR_CMD_3 71
#define IR_CMD_4 68
#define IR_CMD_5 64
#define IR_CMD_6 67
#define IR_CMD_7 7
#define IR_CMD_8 21
#define IR_CMD_9 9

#define CONFIG_SLEEP_TIME_INIT 6  //单位：小时

typedef struct BirdWaterConfig {
  int g_Key;
  int g_IrReceiverCmd;
  int g_WorkState;
  int g_PumpOn;
  int g_MoveSpeed;
  int g_TimeConfig;
  int g_SleepTime;
  int g_WaterTime;
  int g_waterEN;  
  int g_dc12v;
  int g_SSTimer;
  int wakeupsourse;
  int workTimePre;
  int g_Runtime;
};

typedef struct ReceiveStateType {
  int OK;
  int ready;
  int RECV;
  int SmartconfigConnected;
  int WIFICONNECTED;
  int ErrNum;
  };
extern ReceiveStateType ReceiveState;
extern BirdWaterConfig g_BirdWaterConfig,g_BirdWaterConfigBk;
extern void BirdWaterInit(BirdWaterConfig *config);
extern void BirdWaterTaskEn(BirdWaterConfig *config);

extern void BirdWaterLoop(BirdWaterConfig * config);
extern void birdwaterSS(BirdWaterConfig *config);
extern void birdwaterTimer100ms();
extern void birdwaterTaskWater(BirdWaterConfig *config);
extern void birdwaterSetTime(int cmd);
extern void birdwaterTest(int cmd);

extern void Loop100ms(void);

extern void LEDShow(void);

enum MQTT_WORKSTATE {INIT=0,NETCONECT,MQTTUSERCFG,MQTTCONN,MQTTSUB,MQTTPUB};
extern MQTT_WORKSTATE g_MqttWorkState;

